package reflect;

import java.lang.reflect.Method;

public class ReflectDemo7 {
    public static void main(String[] args) throws Exception {
        Person p = new Person();
        p.hehe();  //不能在类的外部调用类的私有成员

        Class cls = Class.forName("reflect.Person");
        Object obj = cls.newInstance();

//        Method method = cls.getMethod("hehe");
        Method method = cls.getDeclaredMethod("hehe");
        method.setAccessible(true);
        method.invoke(obj);


    }
}
